from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token

from meiduo_admin.goods import sku_views, spu_views, image_views
from meiduo_admin.orders import order_views
from meiduo_admin.home import home_views
from meiduo_admin.users import users_views
from meiduo_admin.managers import permission_views

urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),
    url(r'^statistical/total_count/$', home_views.UserTotalCountView.as_view()),
    url(r'^statistical/day_orders/$', home_views.UserDayOrdersCountView.as_view()),
    url(r'^statistical/day_active/$', home_views.UserDayActiveCountView.as_view()),
    url(r'^statistical/day_increment/$', home_views.UserDayIncrementCountView.as_view()),
    url(r'^statistical/month_increment/$', home_views.UserMonthIncrementCountView.as_view()),
    url(r'^statistical/goods_day_views/$', home_views.GoodsDayVisitCountView.as_view()),
    url(r'^users/$', users_views.UsersView.as_view()),
    url(r'^skus/categories/$', sku_views.SKUCategoriesView.as_view()),
    url(r'^goods/brands/simple/$', spu_views.BrandSimpleView.as_view()),
    url(r'^goods/channel/categories/$', spu_views.ParentCategoryView.as_view()),
    url(r'^goods/channel/categories/(?P<cate_id>\d+)/$', spu_views.SubCategoryView.as_view()),
    url(r'^goods/images/$', spu_views.SPUDetailImageView.as_view()),
    url(r'^skus/simple/$', image_views.SKUListView.as_view()),
    url(r'^orders/$', order_views.OrderSimpleListView.as_view()),
    url(r'^orders/(?P<pk>\d+)/$', order_views.OrderDetailView.as_view()),
    url(r'^orders/(?P<order_id>\d+)/status/$', order_views.OrderUpdateStatusView.as_view()),
    url(r'^permission/content_types/$', permission_views.ContenTypeView.as_view()),
]

from rest_framework.routers import SimpleRouter, DefaultRouter

spec_router = DefaultRouter()
spec_router.register('goods/specs', spu_views.SpecificationViewSet, base_name='specs')
urlpatterns += spec_router.urls

image_router = DefaultRouter()
image_router.register('skus/images', image_views.ImageViewSet, base_name='images')
urlpatterns += image_router.urls

sku_router = SimpleRouter()
sku_router.register('skus', sku_views.SKUViewSet, base_name='sku')
urlpatterns += sku_router.urls

goods_router = SimpleRouter()
goods_router.register('goods', spu_views.SPUViewSet, base_name='goods')
urlpatterns += goods_router.urls

option_router = DefaultRouter()
option_router.register('specs/options', spu_views.SpecOptionViewSet, base_name='options')
urlpatterns += option_router.urls

permission_router = DefaultRouter()
permission_router.register('permission/perms', permission_views.PermissionViewSet, base_name='permission')
urlpatterns += permission_router.urls
